Skip to main content

Indexes

Indexes, importantly, the correct ones are essential to get the most of the database and the query. Non-existent or poorly created indexes can adversely impact the performance of your queries

Basic indexing

  1. Run the following query:

    for flight IN flights filter flight.TailNum == "N505JB" return flight
  2. If you profile the query you should see something like this: ArangoDB query profile

  3. You see that the collection is being enumerated in id #2 (Scan Full) and importantly, no indexes are being used

  4. Let's go and create an index next and see what difference it makes

  5. Navigate to the collection you need, in the case the flights collection

    ArangoDB select flights

  6. Next click (+) to add a new index

    ArangoDB add index

  7. Then specify the index details and create it in the background

    • (1) Type: Persistent index
    • (2) Fields: TailNum
    • (3) Name: TailNumIndex (if you dont specify a name arangodb will generate one for you)
    • (4) Click Create , Leaving the rest of the fields as defaults

    ArangoDB create index

  8. You should be able to see the status of the index once created:

    ArangoDB index status

  9. Now go back to the query edit and rerun the query profiler and query.

  10. Compare the plan and execution times ArangoDB query profile

  11. You can clearly see that there wasn't any full scan done and the execution time is significantly better

 
Help us improve

Anything unclear or buggy in this tutorial? Provide Feedback